<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
 */

Route::group([
	'namespace' => 'Api\v1',
	'prefix' => 'v1',
], function () {

	Route::group(['middleware' => ['auth:api', 'admin']], function () {
		Route::resource('user', 'UserController', ['names' => [
			'index' => 'api.user.index',
			'store' => 'api.user.store',
			'edit' => 'api.user.edit',
			'update' => 'api.user.update',
			'destroy' => 'api.user.destroy',
		], 'except' => ['create', 'show']]);
		Route::resource('cate', 'CateController', ['except' => ['create', 'show']]);
		Route::resource('item', 'ItemController', ['except' => ['create', 'show']]);
		Route::resource('note', 'NoteController', ['except' => ['create', 'show']]);
		Route::resource('tag', 'TagController', ['except' => ['create', 'show']]);
		Route::resource('link', 'LinkController', ['except' => ['create', 'show']]);
		Route::resource('comment', 'CommentController', ['except' => ['create', 'show']]);
		Route::resource('message', 'MessageController', ['except' => ['create', 'show']]);
		Route::resource('carousel', 'CarouselController', ['except' => ['create', 'show']]);
		Route::resource('record', 'RecordController', ['except' => ['index', 'create', 'show', 'edit']]);
		Route::patch('changeStatus/{id}', 'RecordController@changeStatus');
		Route::get('completeNote/{id}', 'NoteController@completeNote');

		Route::post('setShowConfig', 'ConfigController@setShowConfig');
		Route::post('setWebsiteSeo', 'ConfigController@setWebsiteSeo');
		Route::get('clearCache', 'ConfigController@clearCache');
		Route::post('setUserInfo', 'ConfigController@setUser');
		Route::get('resumeInfo', 'ConfigController@resume');
		Route::post('setResumeInfo', 'ConfigController@setResumeInfo');
		Route::post('setContactMe', 'ConfigController@setContactMe');
		Route::post('uploadImage', 'UploadController@upload');

		Route::get('counts', 'HomeController@counts');
	});
	// 这些路由必须登录后才能访问
	Route::group(['middleware' => ['auth:api']], function () {
		Route::post('/comment/reply', 'CommentController@reply');
		Route::get('/initial', 'UserController@initial');
		Route::patch('/resetPwd', 'UserController@resetPwd');
		Route::patch('/modifyInfo', 'UserController@modifyInfo');
		Route::post('/changeAvatar', 'UserController@changeAvatar');
		Route::get('/{name}/info', 'UserController@info');
		Route::get('/approve/{item}', 'UserController@approve');
		Route::get('/topic-login/{id}', 'ItemController@topic');
	});

	Route::get('cate/all', 'CateController@all');

	Route::get('/cates', 'CateController@cates');

	Route::get('/carousels', 'CarouselController@carousels');

	Route::get('/notes', 'NoteController@notes');

	Route::get('tag/all', 'TagController@all');

	Route::get('/tags', 'TagController@tags');

	Route::get('/randReply', 'CommentController@randReply');

	Route::get('/topics', 'ItemController@topics');

	Route::get('/recommends', 'ItemController@recommends');

	Route::get('/topics-hot', 'ItemController@hot');

	Route::get('/topic-unlogin/{id}', 'ItemController@topic');

	Route::get('/note/{id}', 'NoteController@note');

	Route::get('/topic/{id}/comments', 'ItemController@comments');

	Route::get('/user/{name}', 'UserController@user');

	Route::post('/auth/token', 'LoginController@login');

	Route::post('/auth/refresh', 'LoginController@refresh');

	Route::post('/register', 'LoginController@register');

	Route::get('/userInfo', 'ConfigController@user');

	Route::post('sendResetMail', 'UserController@sendResetMail');
});
